<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateArticlesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //文章资讯基本表
        Schema::create ('articles', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->uuid ('id')->primary ('id');//uuid主键
            $table->uuid ('create_user_id');//添加人ID
            $table->uuid ('category_id');//分类ID
            $table->uuid ('cover_id');//封面图片ID
            $table->string ('article_author');//作者
            $table->string ('article_source_url');//来源URL
            $table->string ('article_title', 100);//标题
            $table->string ('article_desc', 200);//摘要
            $table->text ('article_content');//文章内容
            $table->tinyInteger ('article_status');//文章状态
            $table->timestamps ();
            $table->foreign ('category_id')->references ('id')->on ('article_category')->onDelete ('cascade');//分类外键
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists ('articles');
    }
}
